home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000098_icon-group-sender _Thu Apr 21 06:30:52 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Sun, 24 Apr 1994 13:54:22 MST
Path: ucbvax!agate!ihnp4.ucsd.edu!swrinde!emory!europa.eng.gtefsd.com!MathWorks.Com!noc.near.net!hopscotch.ksr.com!tim
From: tim@ksr.com (Tim Peters)
Newsgroups: comp.lang.icon
Subject: Re: generate keys of a table?
Message-Id: <2p56is$k0t@hopscotch.ksr.com>
Date: 21 Apr 94 06:30:52 GMT
References: <MIKE.94Apr20181417@majestix.cs.uoregon.edu>
Distribution: inet
Organization: Kendall Square Research
Lines: 36
Nntp-Posting-Host: kaos.ksr.com
Apparently-To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
mike@majestix.cs.uoregon.edu (Mike Haertel) writes:
>Is there a way to enumerate keys of a table (not the entries)?
"key" is builtin generator that does what you're after. See "The Icon
Programming Language", 2nd edition, pgs 74-75. If you have a very old
version of Icon, "key" might not be in it.
Here's an example:
procedure main()
local t, i
t := table()
every i := 1 to 10 do t[i] := "abcdefghij"[i]
every writes( right(!t, 3) )
write()
every writes( right(key(t), 3) )
write()
end
And here's its output:
e b j g d a i f c h
5 2 10 7 4 1 9 6 3 8
key(table) generates table's keys in an arbitrary order, but so long as
you don't fiddle with table in the meantime, it's the same arbitrary
order that !table uses for generating table's entries.
BTW, I believe that if Dr. Griswold had it to do all over again, !table
would generate keys instead of entries.
why-languages-should-be-implemented-but-never-used<wink>-ly y'rs - tim
Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp